package com.quick.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.quick.service.IFtpService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("api/ftp")
@Api(tags = "上传文件")
public class FtpController {
	
	@Autowired
	private IFtpService ftpService;
	/**
	 * 单文件上传
	 * @param multipartFile
	 * @return
	 */
	@PostMapping("upload")
	@ApiOperation(value = "单文件上传",notes = "单文件上传")
	public Map<String,Object> doUpload(@RequestParam("file") MultipartFile multipartFile,
			@RequestParam(value = "type",defaultValue = "image") String type,
			@RequestParam(value = "sizeType",defaultValue = "original") String sizeType,
			@RequestParam(value = "width",defaultValue = "370") Integer width,
			@RequestParam(value = "height",defaultValue = "240") Integer height
			){
		Map<String, Object>  base = new HashMap<String, Object>();
		base.put("type", type);
		base.put("sizeType", sizeType);
		base.put("width", width);
		base.put("height", height);
		return ftpService.uploadFtp(multipartFile,base);
	}
	/**
	 * 多文件上传
	 * @param multipartFiles
	 * @return
	 */
	@PostMapping("multifileUpload")
	@ApiOperation(value = "多文件上传",notes = "多文件上传")
	public Map<String, Object> multifileUpload(@RequestParam("files") MultipartFile[] multipartFiles){
		Map<String, Object>  base = new HashMap<String, Object>();
		return ftpService.multiFileUpload(multipartFiles,base);
	}

}
